﻿<!DOCTYPE html>
<html style="font-size: 50px;">

<head>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="description" />
    <meta name="keywords" content="车行易,sayhi,app,hi,cxy">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit" />
    <meta name="format-detection" content="telephone=no">
    <!-- No Baidu Siteapp-->
    <title>
        一起来sayhi
    </title>


    <script>
        !function (n, e) {
            var t = n.documentElement, i = "orientationchange" in window ? "orientationchange" : "resize", d = function () {
                var n = t.clientWidth;
                if (n) {
                    var e = 50 * (n / 375);
                    //  e = e > 54 ? 54 : e;
                    t.style.fontSize = e + "px";
                }
            };
            n.addEventListener && (e.addEventListener(i, d, !1), n.addEventListener("DOMContentLoaded", d, !1));
        }(document, window);

    </script>


    <link rel="stylesheet" href="css/share.min.css?v=1" type="text/css">


</head>

<body>

<div id="shareMask" onclick="closeShare()" style="position: fixed; z-index: 10; display: none; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, .8)">
    <img  src="./images/share/word.png" style="margin-top: 1rem; margin-left: 1.66rem; width: 4.18rem;">
    <img class="imgMask" src="./images/shareMask.png" alt="请点击右上角按钮">
</div>

    <div class="Mask"><img class="w_h_img" src="" alt="车行易违章查询代办" /></div>
    <!-- share -->

    <div id="shareID" class="share_content ">
        <dl class="firstParty relative hide">
            <dt></dt>
            <dd></dd>
        </dl>
        <div class="secondParty relative hide">
            <dl class="time relative">
                <dt><span class="tens_place day_0"></span><span class="the_unit day_0"></span></dt>
                <dd><span class="month">?</span>月/<span class="year">2017</span></dd>
                <dd class="state"><span class="gold"></span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="more opacity" onclick="toUrl()">查看详情</span></dd>
            </dl>
            <div class="line"></div>
            <dl class="userInfo relative hide">
                <dt></dt>
                <dd></dd>
            </dl>
            <div class="btn opacity" onclick="gotoShare()">
                <span>分享</span>
            </div>
        </div>
    </div>

    <!-- end -->
    <script src="js/cxytongjiV1.js"></script> <!-- 埋点 -->
    <script src="js/jquery.min.js"></script>
    <script src="js/toastV3.min.js"></script>
    <script src="js/JsAPIV2.1.min.js"></script>

    <script language="javascript">

        var userData = { "userType": TypeOfBrowser(), "userId": "", "accountId": "", "token": '', "optionId": getUrlParam('optionId') || '', "avatar": "" };
        var production = window.location.href.indexOf("webservice.cx580.com/") > -1 ? true : false; //是否为生产环境
        var baseUrl = production ? "https://webservice.cx580.com" : "http://192.168.1.166:7070";// 请求接口的正式环境和测环境



        /* ===========    常用事件          =================== */

        // 版本号判断和单点登录,返回字符串小写
        function TypeOfBrowser() {
            var channel = "";
            //支付宝
            if (navigator.userAgent.indexOf("AlipayClient") !== -1) {
                channel = "alipay";
            }
            else if (navigator.userAgent.indexOf("appname_cxycwz") > -1) {
                channel = "app";
            }
            else if (navigator.userAgent.indexOf("MicroMessenger") > -1) {
                channel = "weixin";
            }
            else if (navigator.userAgent.indexOf("QQ") > -1) {
                channel = "qq";
            }
            else {
                channel = "unknown";
            }
            return channel;
        }

        // 获取cookie
        function getCookie(name) {
            var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return unescape(arr[2]);
            else
                return null;
        }

        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }

        /* ================   分享  ==================== */

        var shareTitle = "唯有爱与心情不可以将就";
        var shareUrl = location.href.split("share.html")[0];
        var shareImg = shareUrl + "images/showImg.png";
        var shareDesc = "每天和小易say hi，是我一天心情的开始，你也一起来吧～";
        var shareToNewUrl = location.href.split("share.html")[0] + "share.html" + "?optionId=" + getUrlParam('optionId') + "&beShare=share"; // 新分享的网址，不带参数
        var shareWXUrl = window.location.href; // 当前网址
        var shareChannel = "weiXin,wenXinCircle,alipay,qq"; // app分享渠道

        // beShared>-1，说明是被分享出去的页面
        var beShared = window.location.search.indexOf('beShare=') > -1 || window.location.search.indexOf('from=') > -1 ? true : false;

        // 关闭分享弹窗
        function closeShare() {
            $("#shareMask").hide().find(".imgMask").removeClass("cartoonBottomtoUp");
        }

        // APP和支付宝的按钮点击分享：不要页面默认执行,点击分享按钮才执行
        function gotoShare() {
            //埋点 :ID, attr1，userType, userId, productUserId
            cxyBuryingPoint("H5_E_HD_ClickShare", "点击分享", userData.userType, userData.userId, userData.accountId);

            if (userData.userType == 'weixin' || userData.userType == 'qq') {
                $("#shareMask .imgMask").addClass("cartoonBottomtoUp");
            }
            shareFun(userData.userType, shareTitle, shareImg, shareDesc, shareUrl, shareToNewUrl, shareWXUrl, shareChannel);

        }

        /* ===========    事件          =================== */


        // 初始化请求: 分享
        function initSharedFUN() {

            //埋点 :ID, attr1，userType, userId, productUserId
            cxyBuryingPoint("H5_P_HD_EnteFeedbackpage", "进入sayhi反馈页", userData.userType, userData.userId, userData.accountId);

            AW.toast.show({
                message: '<div class="toastHits">请稍等...</div>',
                type: 'none',
                callContainer: true
            });


            var param = {
                token: userData.token
            };
            $.ajax({
                url: baseUrl + "/sayHi/getSignInInfo",
                type: "GET",
                data: param,
                beforeSend: function () { },
                success: function (res) {
                    //  res = JSON.parse(res);

                    if (res.code == "1000") {
                        var data = res.data;
                        // 背景图片
                        var imgSrc = data.moodImgURL || "./images/share/bg.png";
                        $(".Mask img").attr("src", imgSrc);
                        // 小易语音

                        data.ana && $('.secondParty .userInfo dt').html('<img class="img" src="' + userData.avatar + '" alt=""/>').next('dd').html(data.ana).parents('.userInfo').show();


                        // 奖励金
                        var domGold = JSON.parse(data.encourageGold) ? '获得' + data.gold + '积分，' + data.encourageGold + '元鼓励金' : '获得' + data.gold + '积分';
                        $('.secondParty .state .gold').html(domGold);

                        // 显示页面
                        $('.secondParty').fadeIn();

                        // 日期
                        var newSystemTime = data.signDate.split(/[- : \/]/);
                        var systemTime = new Date(newSystemTime[0], newSystemTime[1] - 1, newSystemTime[2]);

                        $('.secondParty .tens_place').attr('class', 'tens_place day_' + Math.floor(systemTime.getDate() / 10)).next('.the_unit').attr('class', 'tens_place day_' + Math.floor(systemTime.getDate() % 10));
                        $('.secondParty .month').html(systemTime.getMonth()+1).next('.year').html(systemTime.getFullYear());

                        // ============
                        AW.toast.hide();
                    } else {
                        AW.toast.show({
                            message: '<div class="toastHits">' + res.msg + '</div>',
                            type: 'none',
                            callContainer: true
                        });
                    }

                },
                error: function (err) {
                    AW.toast.show({
                        message: '<div class="toastHits">' + err.msg + '</div>',
                        type: 'none',
                        callContainer: true
                    });
                },
                complete: function () {
                    /* if ($(".am-toast .toastHits").html() == "请稍等...") {
                          AW.toast.hide();
                     }*/
                }
            });



        }


        // 初始化请求: 被 分享
        function initBeSharedFUN() {
            //埋点 :ID, attr1，userType, userId, productUserId
            cxyBuryingPoint("H5_P_HD_EnteSharedpage", "进入被分享页", userData.userType, userData.userId, userData.accountId);

            AW.toast.show({
                message: '<div class="toastHits">请稍等...</div>',
                type: 'none',
                callContainer: true
            });


            var param = {
                signId: userData.optionId
            };
            $.ajax({
                url: baseUrl + "/sayHi/getShareInfo",
                type: "GET",
                data: param,
                beforeSend: function () { },
                success: function (res) {
                    //  res = JSON.parse(res);
                   

                    if (res.code == "1000") {
                        // 背景图片
                        $(".Mask img").attr("src", res.data.moodImgURL);
                        // 二维码和分享
                        $('.firstParty').find('dt').html('<img class="img" src="images/share/code_' + userData.userType + '.png" alt="车行易违章查询代办"/>').next('dd').html(res.data.ana).parents('.firstParty').fadeIn();

                        AW.toast.hide();
                    } else {
                        AW.toast.show({
                            message: '<div class="toastHits">' + res.msg + '</div>',
                            type: 'none',
                            callContainer: true
                        });
                    }

                },
                error: function (err) {
                    AW.toast.show({
                        message: '<div class="toastHits">' + err.msg + '</div>',
                        type: 'none',
                        callContainer: true
                    });
                },
                complete: function () {
                    /* if ($(".am-toast .toastHits").html() == "请稍等...") {
                          AW.toast.hide();
                     }*/
                }
            });


        }


        // 页面跳转:只跳去查看金币
        function toUrl() {
            //埋点 :ID, attr1，userType, userId, productUserId
            cxyBuryingPoint("H5_E_HD_ClickCheckDetail", "点击查看奖励详情", userData.userType, userData.userId, userData.accountId);

            window.location.href = shareUrl + "gold.html?token=" + userData.token + "&_wv=66563";
        }


        /* ================   执行 ==================== */
        $(document).ready(function () {

            var keyPre = production ? '' : 'test_';
         
            userData.userType = getCookie(keyPre + 'userType') || TypeOfBrowser(); // .toLowerCase()
            userData.userId = getCookie(keyPre + 'userId') || '';
            userData.token = getCookie(keyPre + 'userToken') || '';
            userData.avatar = getCookie(keyPre + 'thisIsTheAvatarOFsayHi') || '';
            userData.optionId = getUrlParam('optionId') || '';


           shareInitFun(userData.userType, shareTitle, shareImg, shareDesc, shareUrl, shareToNewUrl, shareWXUrl, shareChannel);
        
            // 有from分享和没有token，则说明是被分享
            beShared  ? initBeSharedFUN() : initSharedFUN();//  请求数据


        }); // end


    </script>

</body>


</html>